<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui">
<h:body>
	<ui:composition template="/pages/protected/templates/page.xhtml">
		<ui:define name="divBody">
			<h:form id="usersForm">
				<p:dataTable id="usersTable" value="#{userMB.todosUsers}" var="usuario"
					emptyMessage="#{bundle.noRecords}" paginator="true" rows="10"
					paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
					rowsPerPageTemplate="5,10,15">
					<p:column>
						<f:facet name="header">
							<h:outputText value="#{bundle.nome}" />
						</f:facet>
						<h:outputText value="#{usuario.name}" />
					</p:column>

					<p:column>
						<f:facet name="header">
							<h:outputText value="#{bundle.sobrenome}" />
						</f:facet>
						<h:outputText value="#{usuario.sobrenome}" />
					</p:column>

					<p:column>
						<f:facet name="header">
							<h:outputText value="#{bundle.perfilUser}" />
						</f:facet>
						<h:outputText value="#{usuario.role}" />
					</p:column>
					<p:column>
						<p:spacer width="10px" />
						<p:commandButton value="#{bundle.update}" icon="ui-icon-pencil"
							update=":userAtualizarDialogForm"
							onclick="userAtualizarDialogWidget.show();">
							<f:setPropertyActionListener target="#{userMB.usuario}"
								value="#{usuario}" />
						</p:commandButton>
						<p:spacer width="10px" />
						<p:commandButton value="#{bundle.delete}" icon="ui-icon-trash"
							update=":userDeletarDialogForm"
							onclick="userDeletarDialogWidget.show();">
							<f:setPropertyActionListener target="#{userMB.usuario}"
								value="#{usuario}" />
						</p:commandButton>
						<p:spacer width="10px" />
					</p:column>

				</p:dataTable>
				<p:commandButton value="#{bundle.create} #{bundle.user}"
					icon="ui-icon-plus" update=":userCriarDialogForm"
					actionListener="#{userMB.resetUser()}"
					onclick="userCriarDialogWidget.show();" />
			</h:form>

			<ui:include
				src="/pages/protected/admin/dialogs/userCriarDialog.xhtml" />
			<ui:include
				src="/pages/protected/admin/dialogs/userAtualizarDialog.xhtml" />
			<ui:include
				src="/pages/protected/admin/dialogs/userDeletarDialog.xhtml" />
		</ui:define>
	</ui:composition>
</h:body>
</html>